import java.util.Scanner;

public class Day3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr1 = new int[n];
        for(int i = 0;i<n;i++){
            arr1[i] = sc.nextInt();
        }
        int m = sc.nextInt();
        int[] arr2 = new int[m];
        for(int i = 0;i<n;i++){
            arr2[i] = sc.nextInt();
        }
        int num = func(arr1,arr2);
        System.out.println(num);
    }
    public static int func(int[] arr1,int[] arr2){
        int i = 0;
        int j = 0;
        int n = arr1.length;
        int m = arr2.length;
        int ret = 0;
        for (;i<n;i++){
            while(i + 1<n && arr1[i] == arr1[i+1]) i++;

            i = i-1;
            while(j < m && arr1[i] > arr2[j]){
                j++;
                //ret++;
            }


            //if(arr1[i] == arr2[j-1])
        }
        return ret;
    }
}
